﻿using Bll.User;
using ShareCode.Entity.User;
using Infrastructure.Attributes.Ioc;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
using Infrastructure.Attributes;

namespace ApiApp.Controllers.User
{
    /// <summary>
    /// by zhouxin
    /// action的 900 < SerialNumber < 1000
    ///</summary>
    [ApiController]
    [Route("User/[controller]")]
    [Component(ServiceLifetime.Transient)]
    public class UserApiController : BaseTreeController<UserApiEntity>
    {
        protected override UserApiBll? Bll => (UserApiBll?)base.Bll;

        [Autowired]
        public UserApiBll SetBll { set { this._Bll = value; } }



        [HttpGet]
        public IActionResult Get()
        {
            List<Type> Types = new List<Type>();

            Types.AddRange(typeof(AutofacRegisterModule).Assembly.GetTypes());

            var clazz = Types.Where(t => t.IsClass && !t.IsAbstract);

            foreach (var type in Types)
            {
                var auth = type.GetCustomAttribute<AuthAttribute>();

                if (auth == default)
                {
                    continue;
                }

                Bll!.InitAPI(type, auth);
            }


            return Ok();
        }
    }
}
